# -*- coding: utf-8 -*-
# @Time    : 2021/10/19 9:18
# @Author  : TangDagui
# @Email   : 3297364807@qq.com
# @File    : 宽带连接.py
# @Software: PyCharm
# @Explain ：请勿乱传哈
import requests
import json
import random
import time


def login(user):
    url = 'http://172.16.253.55/portal.do?wlanacname=000000021.210.00&wlanuserip=172.20.53.68&wlanparameter=48.a4.72.60.9d.f2&usermac=48:a4:72:60:9d:f2'
    payload = 'loginType=&auth_type=0&isBindMac1=1&pageid=1&templatetype=1&listbindmac=1&recordmac=0&isRemind=1&loginTimes=&groupId=&distoken=&echostr=&url=&isautoauth=&notice_pic_loop2=%2Fportal%2Fuploads%2Fpc%2Fdemo2%2Fimages%2Fbj.png&notice_pic_loop1=%2Fportal%2Fuploads%2Fpc%2Fdemo2%2Fimages%2Flogo.png&userId={0}&passwd=123&twiceauth=1&remInfo=on'.format(
        user)
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded',
    }
    try:
        response = requests.request('POST', url, headers=headers, data=payload)
    except:
        print("请检查是否已连接学校wifi")


def isConnected():
    try:
        html = requests.get("http://www.baidu.com", timeout=2)
        if len(html.text) == 2381:
            return True
        else:
            return False
    except:
        return False


if __name__ == '__main__':
    count = 0
    while True:
        time.sleep(1)
        if isConnected() == True:
            print("网络正常")
        else:
            count += 1
            print("第{0}次连接".format(count))
            data={"0": "13228645518", "1": "13228645513", "2": "13228645512", "3": "13228645511", "4": "13228645510",
             "5": "13228645508", "6": "13228645507", "7": "13228645500", "8": "13228645497", "800": "13228643979",
             "9": "13228645494", "801": "13228643975", "802": "13228643974", "803": "13228643973", "804": "13228643972",
             "805": "13228643970", "806": "13228643969", "807": "13228643968", "808": "13228643967",
             "809": "13228643966", "810": "13228643965", "811": "13228643964", "812": "13228643963",
             "813": "13228643961", "814": "13228643959", "815": "13228643957", "816": "13228643955",
             "817": "13228643953", "818": "13228643949", "819": "13228643945", "820": "13228643944",
             "821": "13228643941", "822": "13228643938", "823": "13228643937", "824": "13228643933",
             "825": "13228643930", "826": "13228643926", "827": "13228643925", "828": "13228643923",
             "829": "13228643922", "830": "13228643921", "831": "13228643919", "832": "13228643916",
             "833": "13228643912", "834": "13228643910", "835": "13228643909", "836": "13228643906",
             "837": "13228643900", "838": "13228643897", "839": "13228643890", "840": "13228643889",
             "841": "13228643883", "600": "13228644354", "842": "13228643882", "601": "13228644353",
             "843": "13228643880", "602": "13228644352", "844": "13228643868", "603": "13228644349",
             "845": "13228643859", "604": "13228644348", "846": "13228643856", "605": "13228644345",
             "847": "13228643852", "606": "13228644344", "848": "13228643843", "607": "13228644342",
             "608": "13228644340", "609": "13228644339", "610": "13228644337", "611": "13228644336",
             "612": "13228644335", "613": "13228644334", "614": "13228644331", "615": "13228644330",
             "616": "13228644329", "617": "13228644327", "618": "13228644325", "619": "13228644324",
             "620": "13228644323", "621": "13228644321", "622": "13228644319", "623": "13228644315",
             "624": "13228644311", "625": "13228644310", "626": "13228644306", "627": "13228644304",
             "628": "13228644302", "629": "13228644300", "630": "13228644299", "631": "13228644296",
             "632": "13228644295", "633": "13228644293", "634": "13228644291", "635": "13228644289",
             "636": "13228644288", "637": "13228644286", "638": "13228644285", "639": "13228644283",
             "640": "13228644281", "641": "13228644280", "400": "13228644739", "642": "13228644278",
             "401": "13228644737", "643": "13228644277", "402": "13228644736", "644": "13228644276",
             "403": "13228644733", "645": "13228644274", "404": "13228644731", "646": "13228644269",
             "405": "13228644730", "647": "13228644267", "406": "13228644729", "648": "13228644266",
             "407": "13228644728", "649": "13228644265", "408": "13228644727", "409": "13228644723",
             "650": "13228644264", "651": "13228644263", "410": "13228644722", "652": "13228644261",
             "411": "13228644719", "653": "13228644257", "412": "13228644717", "654": "13228644253",
             "413": "13228644716", "655": "13228644252", "414": "13228644715", "656": "13228644251",
             "415": "13228644714", "657": "13228644249", "416": "13228644713", "658": "13228644247",
             "417": "13228644711", "659": "13228644246", "418": "13228644710", "419": "13228644709",
             "660": "13228644244", "661": "13228644243", "420": "13228644707", "662": "13228644241",
             "421": "13228644706", "663": "13228644240", "422": "13228644703", "664": "13228644237",
             "423": "13228644701", "665": "13228644236", "424": "13228644700", "666": "13228644235",
             "425": "13228644699", "667": "13228644234", "426": "13228644695", "668": "13228644233",
             "427": "13228644694", "669": "13228644232", "428": "13228644693", "429": "13228644691",
             "670": "13228644230", "671": "13228644229", "430": "13228644686", "672": "13228644226",
             "431": "13228644685", "673": "13228644225", "432": "13228644683", "674": "13228644221",
             "433": "13228644680", "675": "13228644220", "434": "13228644678", "676": "13228644218",
             "435": "13228644676", "677": "13228644214", "436": "13228644673", "678": "13228644212",
             "437": "13228644672", "679": "13228644211", "438": "13228644671", "439": "13228644670",
             "680": "13228644207", "681": "13228644205", "440": "13228644668", "682": "13228644203",
             "441": "13228644667", "683": "13228644202", "200": "13228645132", "442": "13228644665",
             "684": "13228644201", "201": "13228645131", "443": "13228644663", "685": "13228644200",
             "202": "13228645130", "444": "13228644662", "686": "13228644198", "203": "13228645129",
             "445": "13228644661", "687": "13228644196", "204": "13228645128", "446": "13228644660",
             "688": "13228644194", "205": "13228645126", "447": "13228644659", "689": "13228644192",
             "206": "13228645125", "448": "13228644657", "207": "13228645124", "449": "13228644655",
             "208": "13228645123", "209": "13228645122", "690": "13228644189", "691": "13228644188",
             "450": "13228644654", "692": "13228644182", "451": "13228644653", "693": "13228644181",
             "210": "13228645121", "452": "13228644652", "694": "13228644178", "211": "13228645120",
             "453": "13228644650", "695": "13228644177", "212": "13228645119", "454": "13228644643",
             "696": "13228644176", "213": "13228645117", "455": "13228644641", "697": "13228644175",
             "214": "13228645115", "456": "13228644639", "698": "13228644174", "215": "13228645110",
             "457": "13228644637", "699": "13228644172", "216": "13228645109", "458": "13228644634",
             "217": "13228645106", "459": "13228644631", "218": "13228645105", "219": "13228645104",
             "460": "13228644629", "461": "13228644627", "220": "13228645103", "462": "13228644622",
             "221": "13228645101", "463": "13228644620", "222": "13228645099", "464": "13228644619",
             "223": "13228645098", "465": "13228644618", "224": "13228645097", "466": "13228644617",
             "225": "13228645096", "467": "13228644614", "226": "13228645095", "468": "13228644610",
             "227": "13228645093", "469": "13228644607", "228": "13228645092", "229": "13228645091",
             "470": "13228644602", "471": "13228644601", "230": "13228645090", "472": "13228644597",
             "231": "13228645089", "473": "13228644596", "232": "13228645088", "474": "13228644595",
             "233": "13228645087", "475": "13228644594", "234": "13228645086", "476": "13228644591",
             "235": "13228645085", "477": "13228644590", "236": "13228645084", "478": "13228644589",
             "237": "13228645082", "479": "13228644587", "238": "13228645080", "239": "13228645078",
             "480": "13228644584", "481": "13228644582", "240": "13228645077", "482": "13228644581",
             "241": "13228645076", "483": "13228644580", "242": "13228645073", "484": "13228644577",
             "243": "13228645072", "485": "13228644575", "244": "13228645071", "486": "13228644574",
             "245": "13228645068", "487": "13228644573", "246": "13228645067", "488": "13228644572",
             "247": "13228645066", "489": "13228644571", "248": "13228645065", "249": "13228645062",
             "490": "13228644568", "491": "13228644567", "250": "13228645057", "492": "13228644563",
             "251": "13228645055", "493": "13228644561", "252": "13228645054", "494": "13228644557",
             "253": "13228645051", "495": "13228644554", "254": "13228645038", "496": "13228644553",
             "255": "13228645035", "497": "13228644551", "256": "13228645031", "498": "13228644545",
             "257": "13228645026", "499": "13228644544", "258": "13228645025", "259": "13228645024",
             "260": "13228645023", "261": "13228645022", "262": "13228645018", "263": "13228645016",
             "264": "13228645015", "265": "13228645014", "266": "13228645012", "267": "13228645010",
             "268": "13228644996", "269": "13228644994", "270": "13228644992", "271": "13228644989",
             "272": "13228644985", "273": "13228644984", "274": "13228644983", "275": "13228644980",
             "276": "13228644978", "277": "13228644977", "278": "13228644975", "279": "13228644973",
             "280": "13228644972", "281": "13228644971", "282": "13228644970", "283": "13228644966",
             "284": "13228644963", "285": "13228644961", "286": "13228644960", "287": "13228644958",
             "288": "13228644957", "289": "13228644956", "290": "13228644954", "291": "13228644953",
             "292": "13228644952", "293": "13228644951", "294": "13228644950", "295": "13228644949",
             "296": "13228644948", "297": "13228644946", "298": "13228644945", "299": "13228644944",
             "700": "13228644167", "701": "13228644160", "702": "13228644155", "703": "13228644152",
             "704": "13228644150", "705": "13228644147", "706": "13228644144", "707": "13228644142",
             "708": "13228644141", "709": "13228644139", "710": "13228644137", "711": "13228644136",
             "712": "13228644135", "713": "13228644133", "714": "13228644132", "715": "13228644131",
             "716": "13228644129", "717": "13228644128", "718": "13228644125", "719": "13228644124",
             "720": "13228644123", "721": "13228644122", "722": "13228644121", "723": "13228644120",
             "724": "13228644113", "725": "13228644110", "726": "13228644109", "727": "13228644107",
             "728": "13228644103", "729": "13228644102", "730": "13228644100", "731": "13228644099",
             "732": "13228644097", "733": "13228644096", "734": "13228644095", "735": "13228644089",
             "736": "13228644088", "737": "13228644087", "738": "13228644086", "739": "13228644085",
             "740": "13228644084", "741": "13228644081", "500": "13228644543", "742": "13228644078",
             "501": "13228644539", "743": "13228644076", "502": "13228644537", "744": "13228644075",
             "503": "13228644535", "745": "13228644073", "504": "13228644534", "746": "13228644072",
             "505": "13228644533", "747": "13228644070", "506": "13228644532", "748": "13228644068",
             "507": "13228644531", "749": "13228644066", "508": "13228644529", "509": "13228644528",
             "750": "13228644064", "751": "13228644063", "510": "13228644527", "752": "13228644057",
             "511": "13228644526", "753": "13228644056", "512": "13228644525", "754": "13228644055",
             "513": "13228644523", "755": "13228644054", "514": "13228644522", "756": "13228644053",
             "515": "13228644517", "757": "13228644051", "516": "13228644516", "758": "13228644050",
             "517": "13228644515", "759": "13228644046", "518": "13228644514", "519": "13228644511",
             "760": "13228644045", "761": "13228644044", "520": "13228644510", "762": "13228644043",
             "521": "13228644509", "763": "13228644041", "522": "13228644507", "764": "13228644040",
             "523": "13228644505", "765": "13228644039", "524": "13228644504", "766": "13228644038",
             "525": "13228644502", "767": "13228644037", "526": "13228644500", "768": "13228644035",
             "527": "13228644498", "769": "13228644021", "528": "13228644497", "529": "13228644495",
             "770": "13228644020", "771": "13228644018", "530": "13228644494", "772": "13228644017",
             "531": "13228644493", "773": "13228644016", "532": "13228644492", "774": "13228644015",
             "533": "13228644491", "775": "13228644013", "534": "13228644488", "776": "13228644012",
             "535": "13228644487", "777": "13228644010", "536": "13228644485", "778": "13228644009",
             "537": "13228644479", "779": "13228644007", "538": "13228644477", "539": "13228644476",
             "780": "13228644006", "781": "13228644005", "540": "13228644475", "782": "13228644003",
             "541": "13228644474", "783": "13228644002", "300": "13228644943", "542": "13228644473",
             "784": "13228644001", "301": "13228644942", "543": "13228644472", "785": "13228643997",
             "302": "13228644941", "544": "13228644471", "786": "13228643996", "303": "13228644937",
             "545": "13228644469", "787": "13228643995", "304": "13228644933", "546": "13228644463",
             "788": "13228643994", "305": "13228644932", "547": "13228644462", "789": "13228643993",
             "306": "13228644931", "548": "13228644461", "307": "13228644929", "549": "13228644460",
             "308": "13228644928", "309": "13228644917", "790": "13228643991", "791": "13228643990",
             "550": "13228644457", "792": "13228643989", "551": "13228644455", "793": "13228643988",
             "310": "13228644916", "552": "13228644454", "794": "13228643986", "311": "13228644915",
             "553": "13228644453", "795": "13228643985", "312": "13228644914", "554": "13228644452",
             "796": "13228643984", "313": "13228644912", "555": "13228644450", "797": "13228643983",
             "314": "13228644911", "556": "13228644447", "798": "13228643981", "315": "13228644908",
             "557": "13228644442", "799": "13228643980", "316": "13228644907", "558": "13228644441",
             "317": "13228644906", "559": "13228644440", "318": "13228644904", "319": "13228644902",
             "560": "13228644439", "561": "13228644438", "320": "13228644901", "562": "13228644437",
             "321": "13228644900", "563": "13228644435", "322": "13228644899", "564": "13228644433",
             "323": "13228644894", "565": "13228644432", "324": "13228644892", "566": "13228644431",
             "325": "13228644891", "567": "13228644429", "326": "13228644884", "568": "13228644428",
             "327": "13228644879", "569": "13228644423", "328": "13228644872", "329": "13228644866",
             "570": "13228644422", "571": "13228644420", "330": "13228644861", "572": "13228644415",
             "331": "13228644858", "573": "13228644414", "332": "13228644857", "574": "13228644413",
             "333": "13228644856", "575": "13228644412", "334": "13228644855", "576": "13228644411",
             "335": "13228644853", "577": "13228644407", "336": "13228644852", "578": "13228644405",
             "337": "13228644849", "579": "13228644403", "338": "13228644848", "339": "13228644847",
             "580": "13228644401", "581": "13228644400", "340": "13228644846", "582": "13228644399",
             "341": "13228644845", "583": "13228644398", "100": "13228645315", "342": "13228644843",
             "584": "13228644396", "101": "13228645314", "343": "13228644842", "585": "13228644393",
             "102": "13228645313", "344": "13228644839", "586": "13228644388", "103": "13228645312",
             "345": "13228644837", "587": "13228644386", "104": "13228645311", "346": "13228644836",
             "588": "13228644385", "105": "13228645309", "347": "13228644834", "589": "13228644384",
             "106": "13228645307", "348": "13228644833", "107": "13228645303", "349": "13228644830",
             "108": "13228645302", "109": "13228645300", "590": "13228644379", "591": "13228644377",
             "350": "13228644829", "592": "13228644375", "351": "13228644826", "593": "13228644374",
             "110": "13228645299", "352": "13228644824", "594": "13228644368", "111": "13228645292",
             "353": "13228644822", "595": "13228644366", "112": "13228645290", "354": "13228644817",
             "596": "13228644365", "113": "13228645289", "355": "13228644816", "597": "13228644360",
             "114": "13228645285", "356": "13228644815", "598": "13228644359", "115": "13228645283",
             "357": "13228644814", "599": "13228644356", "116": "13228645282", "358": "13228644810",
             "117": "13228645280", "359": "13228644808", "118": "13228645278", "119": "13228645277",
             "10": "13228645492", "11": "13228645491", "12": "13228645489", "13": "13228645485", "14": "13228645484",
             "15": "13228645481", "16": "13228645480", "17": "13228645479", "18": "13228645478", "19": "13228645477",
             "360": "13228644806", "361": "13228644804", "120": "13228645274", "362": "13228644803",
             "121": "13228645271", "363": "13228644802", "122": "13228645269", "364": "13228644801",
             "123": "13228645267", "365": "13228644800", "124": "13228645266", "366": "13228644799",
             "125": "13228645259", "367": "13228644797", "126": "13228645257", "368": "13228644796",
             "127": "13228645255", "369": "13228644795", "128": "13228645251", "129": "13228645249",
             "20": "13228645475", "21": "13228645471", "22": "13228645465", "23": "13228645461", "24": "13228645460",
             "25": "13228645458", "26": "13228645456", "27": "13228645455", "28": "13228645453", "29": "13228645452",
             "370": "13228644793", "371": "13228644792", "130": "13228645244", "372": "13228644791",
             "131": "13228645242", "373": "13228644790", "132": "13228645240", "374": "13228644789",
             "133": "13228645239", "375": "13228644784", "134": "13228645237", "376": "13228644782",
             "135": "13228645236", "377": "13228644781", "136": "13228645234", "378": "13228644779",
             "137": "13228645233", "379": "13228644778", "138": "13228645232", "139": "13228645231",
             "30": "13228645451", "31": "13228645445", "32": "13228645444", "33": "13228645442", "34": "13228645441",
             "35": "13228645440", "36": "13228645439", "37": "13228645437", "38": "13228645435", "39": "13228645433",
             "380": "13228644775", "381": "13228644774", "140": "13228645230", "382": "13228644772",
             "141": "13228645227", "383": "13228644770", "142": "13228645225", "384": "13228644769",
             "143": "13228645223", "385": "13228644768", "144": "13228645220", "386": "13228644763",
             "145": "13228645219", "387": "13228644761", "146": "13228645217", "388": "13228644760",
             "147": "13228645213", "389": "13228644759", "148": "13228645212", "149": "13228645211",
             "40": "13228645431", "41": "13228645423", "42": "13228645421", "43": "13228645420", "44": "13228645415",
             "45": "13228645414", "46": "13228645413", "47": "13228645411", "48": "13228645405", "49": "13228645402",
             "390": "13228644757", "391": "13228644756", "150": "13228645210", "392": "13228644755",
             "151": "13228645208", "393": "13228644751", "152": "13228645207", "394": "13228644749",
             "153": "13228645203", "395": "13228644747", "154": "13228645202", "396": "13228644745",
             "155": "13228645201", "397": "13228644744", "156": "13228645200", "398": "13228644743",
             "157": "13228645199", "399": "13228644741", "158": "13228645197", "159": "13228645196",
             "50": "13228645400", "51": "13228645399", "52": "13228645398", "53": "13228645396", "54": "13228645395",
             "55": "13228645394", "56": "13228645388", "57": "13228645387", "58": "13228645386", "59": "13228645384",
             "160": "13228645194", "161": "13228645192", "162": "13228645191", "163": "13228645190",
             "164": "13228645189", "165": "13228645187", "166": "13228645186", "167": "13228645185",
             "168": "13228645184", "169": "13228645183", "60": "13228645383", "61": "13228645382", "62": "13228645381",
             "63": "13228645379", "64": "13228645376", "65": "13228645372", "66": "13228645371", "67": "13228645370",
             "68": "13228645369", "69": "13228645368", "170": "13228645182", "171": "13228645181", "172": "13228645180",
             "173": "13228645179", "174": "13228645177", "175": "13228645174", "176": "13228645173",
             "177": "13228645172", "178": "13228645171", "179": "13228645169", "70": "13228645366", "71": "13228645365",
             "72": "13228645364", "73": "13228645363", "74": "13228645361", "75": "13228645360", "76": "13228645359",
             "77": "13228645355", "78": "13228645354", "79": "13228645350", "180": "13228645167", "181": "13228645166",
             "182": "13228645164", "183": "13228645163", "184": "13228645159", "185": "13228645157",
             "186": "13228645155", "187": "13228645154", "188": "13228645152", "189": "13228645150",
             "80": "13228645349", "81": "13228645345", "82": "13228645344", "83": "13228645343", "84": "13228645342",
             "85": "13228645340", "86": "13228645339", "87": "13228645337", "88": "13228645334", "89": "13228645331",
             "190": "13228645149", "191": "13228645147", "192": "13228645146", "193": "13228645143",
             "194": "13228645141", "195": "13228645140", "196": "13228645137", "197": "13228645136",
             "198": "13228645135", "199": "13228645133", "90": "13228645330", "91": "13228645329", "92": "13228645327",
             "93": "13228645326", "94": "13228645325", "95": "13228645324", "96": "13228645322", "97": "13228645319",
             "98": "13228645317", "99": "13228645316"}

            mJson = json.loads(json.dumps(data))
            mUser = mJson["{}".format(random.randint(0, len(mJson)))]
            login(mUser)
